{UTF-8}
Unit ListNode;
Interface
Type
	t_size = 	word;
Const
	MAX_SIZE : t_size = 1024;
Type
	PListNode = ^TListNode;
	TListNode = object
		Private
			size_data:	t_size;
			data:		pointer;
			next:		PListNode;
			prev:		PListNode;
		Public
			Constructor	init(var arg; s:t_size);
			Destructor	done;
			Procedure	get_data(var arg);
			Function	get_next:PListNode;
			Function	get_prev:PListNode;
			Procedure	set_next(ptr:PListNode);
			Procedure	set_prev(ptr:PListNode);
			Function	equal(var arg):boolean;
			Function	get_data_ptr:pointer;
		end;
		Procedure	copyArgToPtr(var Arg; const ptr:pointer; const s:t_size);
		Procedure	copyPtrToArg(const ptr:pointer; var Arg; const s:t_size);
Implementation
Type
	buffer = array[1..1024] of byte;
	pbuffer = ^buffer;
Procedure copyArgToPtr;
var
	a:array[1..1024] of byte absolute arg;
	buf:pbuffer;
	i:t_size;
begin
	buf:=ptr;
	for i:=1 to s do
		buf^[i]:=a[i];
end;
Procedure copyPtrToArg;
var
	a:array[1..1024] of byte absolute arg;
	buf:pbuffer;
	i:t_size;
begin
	buf:=ptr;
	for i:=1 to s do
		a[i]:=buf^[i];
end;
Constructor TListNode.init;
begin
	if (s > MAX_SIZE) then Fail;
	size_data:=s;
	next:=nil;
	prev:=nil;
	GetMem(data, size_data);
	copyArgToPtr(arg, data, size_data);
end;
Destructor TListNode.done;
begin
	if (data <> nil) then
	FreeMem(data,size_data);
end;
Procedure TListNode.get_data;
begin
	copyPtrToArg(data, arg, size_data);
end;
Function TListNode.get_next;
begin
	get_next:=next;
end;
Function TListNode.get_prev;
begin
	get_prev:=prev;
end;
Procedure TlistNode.set_next;
begin
	next:=ptr;
end;
Procedure TlistNode.set_prev;
begin
	prev:=ptr;
end;
Function TListNode.equal;
var
	a:array[1..1024] of byte absolute arg;
	i:t_size;
	buf:pbuffer;
begin
	buf:=data;
	for i:=1 to size_data do
		if (a[i] <> buf^[i]) then
			begin
				equal:=false;
				exit;
			end;
	equal:=true;
end;
Function TListNode.get_data_ptr;
begin
	get_data_ptr:=data;
end;
end.